<template>
	<view class="setup">
		<block v-for="(item,index) in list" :key="index">
			<profile-list-item :item="item" :index="index" @selectItem="selectItem"></profile-list-item>
		</block>
		<button class="main-button" @tap="logout">退出登录</button>
	</view>
</template>

<script>
	import profileListItem from "../../components/profile/profile-list-item.vue"
	import * as Types from '../../store/constants'
	export default {
		data() {
			return {
				list: [{
						name: "账号与安全",
						tapType: "router",
						_name: "change-password"
					},
					{
						name: "绑定邮箱",
						tapType: "router",
						_name: "change-email"
					},
					{
						name: "资料编辑",
						tapType: "router",
						_name: "user-edit"
					},
					{
						name: "小纸条",
						tapType: "",
						_name: ""
					},
					{
						name: "清除缓存",
						tapType: "clear",
						_name: ""
					},
					{
						name: "意见反馈",
						tapType: "router",
						_name: "user-help"
					},
					{
						name: "关于糗百",
						tapType: "router",
						_name: "user-about"
					}
				]
			};
		},
		components: {
			profileListItem
		},
		methods: {
			selectItem(index) {
				console.log(index)
			},
			logout() {
				this.$store.dispatch(Types.logoutAction).then(() => {
					uni.removeStorageSync('user')
					this.$Router.push({
						name: 'profile'
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.setup {
		padding: 0 20upx;
	}
</style>
